Skip to content

test(math): strengthen CoPrimeCheck regression tests (R50-T040) - #78

Open
nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T040
Open

nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T040

Conversation

@nishadaniket174

@nishadaniket174 nishadaniket174 commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

This PR strengthens the regression tests for CoPrimeCheck in Maths/CoPrimeCheck.js to protect its coprimality condition against plausible one-line logic mutations.

The function determines whether two integers are coprime by checking whether their greatest common divisor (GCD) is exactly 1.

Changes Made

  • Improved the JSDoc documentation for CoPrimeCheck, including its inputs, return value, preconditions, and coprimality invariant.
  • Clarified the mathematical definition of coprime numbers and corrected the existing documentation.
  • Expanded Maths/test/CoPrimeCheck.test.js with explicit regression fixtures:
    • (1, 1) → true (smallest valid coprime fixture).
    • (2, 9) → true (prime and composite numbers with no common divisor).
    • (9, 11) → true (composite and prime numbers that are coprime).
    • (9, 12) → false (shared divisor 3).
    • (9, 3) → false (composite 9 has divisor 3).
  • Added checks for symmetry, repeatability, determinism, and input non-mutation.
  • Added a regression assertion for (0, 0) to catch an incorrect boundary condition such as changing GCD === 1 to GCD <= 1.
  • Added work/R50-T040/WORK_LOG.md to document the analysis, fixtures, mutation experiment, and verification results.
  • Added work/R50-T040/check.py to automate focused tests, deliberate mutation verification, and the full repository test suite.

Mutation Testing

A plausible one-line mutation was introduced temporarily:

GetEuclidGCD(firstNumber, secondNumber) <= 1

The regression tests correctly detect this mistake because GCD(0, 0) = 0, which must return false, not true.

The deliberate mutation is used only for verification and is not included in the final implementation.

Testing and Verification

The following checks passed:

  • Focused tests: npx vitest run Maths/test/CoPrimeCheck.test.js (18 tests passed).
  • Mutation verification: confirmed that the deliberate boundary-condition mutation causes the regression tests to fail.
  • Full repository test suite: npm test (347 test files passed, 12,031 tests passed).
  • Code style: npm run check-style passed.

Run the complete task-specific verification using:

python3 work/R50-T040/check.py

Related Issue

Closes #40

Task: R50-T040
Target file: Maths/CoPrimeCheck.js
Function: CoPrimeCheck

All task-specific verification evidence is maintained under work/R50-T040/.

@nishadaniket174
nishadaniket174 force-pushed the student/e26b07f0789/R50-T040 branch from 20a0b68 to 12379e3 Compare November 21, 2026 14:37
@nishadaniket174 nishadaniket174 changed the title Student/e26b07f0789/r50 t040 test(math): strengthen CoPrimeCheck regression tests (R50-T040) Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANIKET KUMAR NISHAD — R50-T040: Strengthen the tests of CoPrimeCheck (CoPrimeCheck.js) [Maths/CoPrimeCheck.js]

1 participant